#!/usr/bin/env python
# coding: utf-8

# 作业：
# 
# 1.随机数生成六个班的考试成绩，3门考试：Python、数学、语文。每个班50人
# 
# 2.将六个班的考试成绩进行合并得到score
# 
# 3.生成性别数组sex，水平叠加数组sex和score得到data
# 
# 4.分别计算男女生各科成绩统计指标：最小值、最大值、平均分、中位数、标准差

# In[1]:


import numpy as np


# In[21]:


# 1.随机数生成六个班的考试成绩，3门考试：Python、数学、语文。每个班50人
c1 = np.random.randint(0,101,size = (50,3))
c2 = np.random.randint(0,101,size = (50,3))
c3 = np.random.randint(0,101,size = (50,3))
c4 = np.random.randint(0,101,size = (50,3))
c5 = np.random.randint(0,101,size = (50,3))
c6 = np.random.randint(0,101,size = (50,3))


# In[23]:


# 2.将六个班的考试成绩进行合并得到score
score = np.concatenate((c1,c2,c3,c4,c5,c6))
score


# In[35]:


# 3.生成性别数组sex，水平叠加数组sex和score得到data
gender = np.random.randint(2,size=(300,1))
data = np.concatenate((score,gender),axis=1)
data


# In[50]:


# 4.分别计算男女生各科成绩统计指标：最小值、最大值、平均分、中位数、标准差    
# 指标命名：性别_科目_统计指标
# 所有男生数据的索引
index_m = np.argwhere(data[:,3] == 1)  
# 所有女生数据的索引
index_f = np.argwhere(data[:,3] == 0)  

# 最小值
f_py_min = np.min(data[index_f][:,:,0])
m_py_min = np.min(data[index_m][:,:,0])
f_math_min = np.min(data[index_f][:,:,1])
m_math_min = np.min(data[index_m][:,:,1])
f_ch_min = np.min(data[index_f][:,:,2])
m_ch_min = np.min(data[index_m][:,:,2])
print('女生python最低分为%d' % f_py_min)
print('男生python最低分为%d' % m_py_min)
print('女生数学最低分为%d' % f_math_min)
print('男生数学最低分为%d' % m_math_min)
print('女生语文最低分为%d' % f_ch_min)
print('男生语文最低分为%d' % m_ch_min)


# In[51]:


# 最大值
f_py_max = np.max(data[index_f][:,:,0])
m_py_max = np.max(data[index_m][:,:,0])
f_math_max = np.max(data[index_f][:,:,1])
m_math_max = np.max(data[index_m][:,:,1])
f_ch_max = np.max(data[index_f][:,:,2])
m_ch_max = np.max(data[index_m][:,:,2])
print('女生python最高分为%d' % f_py_max)
print('男生python最高分为%d' % m_py_max)
print('女生数学最高分为%d' % f_math_max)
print('男生数学最高分为%d' % m_math_max)
print('女生语文最高分为%d' % f_ch_max)
print('男生语文最高分为%d' % m_ch_max)


# In[55]:


# 平均分
f_py_mean = np.mean(data[index_f][:,:,0])
m_py_mean = np.mean(data[index_m][:,:,0])
f_math_mean = np.mean(data[index_f][:,:,1])
m_math_mean = np.mean(data[index_m][:,:,1])
f_ch_mean = np.mean(data[index_f][:,:,2])
m_ch_mean = np.mean(data[index_m][:,:,2])
print('女生python平均分为%d' % f_py_mean)
print('男生python平均分为%d' % m_py_mean)
print('女生数学平均分为%d' % f_math_mean)
print('男生数学平均分为%d' % m_math_mean)
print('女生语文平均分为%d' % f_ch_mean)
print('男生语文平均分为%d' % m_ch_mean)


# In[56]:


# 中位数
f_py_median = np.median(data[index_f][:,:,0])
m_py_median = np.median(data[index_m][:,:,0])
f_math_median = np.median(data[index_f][:,:,1])
m_math_median = np.median(data[index_m][:,:,1])
f_ch_median = np.median(data[index_f][:,:,2])
m_ch_median = np.median(data[index_m][:,:,2])
print('女生python中位数为%d' % f_py_median)
print('男生python中位数为%d' % m_py_median)
print('女生数学中位数为%d' % f_math_median)
print('男生数学中位数为%d' % m_math_median)
print('女生语文中位数为%d' % f_ch_median)
print('男生语文中位数为%d' % m_ch_median)


# In[57]:


# 标准差
f_py_std = np.std(data[index_f][:,:,0])
m_py_std = np.std(data[index_m][:,:,0])
f_math_std = np.std(data[index_f][:,:,1])
m_math_std = np.std(data[index_m][:,:,1])
f_ch_std = np.std(data[index_f][:,:,2])
m_ch_std = np.std(data[index_m][:,:,2])
print('女生python标准差为%d' % f_py_std)
print('男生python标准差为%d' % m_py_std)
print('女生数学标准差为%d' % f_math_std)
print('男生数学标准差为%d' % m_math_std)
print('女生语文标准差为%d' % f_ch_std)
print('男生语文标准差为%d' % m_ch_std)

